package Interview;

import java.util.Scanner;

/**
 * Created by loso on 2017/3/30.
 */
public class _toutiao_2017330Test1 {
    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        while (input.hasNext()) {
            int n = input.nextInt();
            int[] mynum = new int[n];
            for (int i = 0; i < n; i++) {
                mynum[i] = input.nextInt();
            }
            int[] output = new int[2];
            int i = 1;
            int j = 1;
            int length = 0;
            boolean flag = false;
            for (; i < mynum.length && j < mynum.length; ) {
                if (mynum[i - 1] > mynum[i]) {
                    j = i + 1;
                    for (; i < mynum.length && j < mynum.length; ) {
                        if (flag == false && mynum[j - 1] > mynum[j]) {
                            flag = true;
                        }
                        if (flag == true && mynum[j - 1] < mynum[j] && mynum[j] > mynum[i]) {
                            if ((j - 1 - i) > length) {
                                output[0] = i;
                                output[1] = j - 1;
                                length = j - 1 - i;
                                flag = false;
                                i = j;
                                break;
                            }
                        }
                        j++;

                    }
                } else {
                    i++;
                }

            }
            if (length == 0) {
                output[0] = -1;
                output[1] = -1;
            }
            System.out.print(output[0] + ' ');
            System.out.print(output[1]);
        }

    }

}
